<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/global/jsp-header.jsp"%>
<c:set var="workerRoleAddVisable" value="${d:accessUri('/role/worker-role-add.do',pageContext.request) }"></c:set>
<c:set var="workerRoleDeleteVisable" value="${d:accessUri('/role/worker-role-delete.do',pageContext.request) }"></c:set>
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html">
		<title>角色人员管理</title>
		<%@ include file="/global/ligerui-header.jsp"%>
		<script type="text/javascript">
		var manager = null;
		$(function(){	
			$("#tree").ligerTree({ checkbox: false, parentIcon: null, childIcon: null });
			manager = $("#tree").ligerGetTreeManager();
		});
		
		function collapseAll(){
            manager.collapseAll();
        }

        function expandAll(){
            manager.expandAll();
        }
        
        <c:if test="${workerRoleAddVisable }">
        function addWorker(roleId){
        	replaceCurIframe("添加角色人员",'/role/worker-role-setting.do?o=a&role.roleId='+roleId);
        }
        </c:if>
        
        <c:if test="${workerRoleDeleteVisable }">
        function deleteWorker(roleId){
        	replaceCurIframe("删除角色人员",'/role/worker-role-setting.do?o=d&role.roleId='+roleId);
        }
        </c:if> 
        function replaceCurIframe(text,url){
        	window.parent.f_overrideTab(text+"(${role.roleName })",url);
        }
        </script>
	</head>
<body>
	<div class="container ">
		<div class="content">
			<div><h3>角色名称:${role.roleName }</h3></div>
			<a class="l-button" onclick="collapseAll()" style="float:left;margin-right:10px;">折叠全部</a> 
		    <a class="l-button" onclick="expandAll()" style="float:left;margin-right:10px;">张开全部</a> 
		    <c:if test="${workerRoleAddVisable }">
				<a class="l-button" onclick="addWorker(${role.roleId})" style="float:left;margin-right:10px;">添加员工人员</a>
			</c:if>
			<c:if test="${workerRoleDeleteVisable }">
			<a class="l-button" onclick="deleteWorker(${role.roleId})" style="float:left;margin-right:10px;">删除角色人员</a>
			</c:if> 
			 <div style="width:250px; border:1px solid #ccc; overflow:auto;clear: both;">
			    <ul id="tree">
			    	<c:forEach items="${roleOfWorker }" var="item">
			        <li isexpand="false">
			            <span>${item.deptName }</span>
			            <ul>
			            	<c:forEach items="${item.subItems }" var="groupItem">
				                <li isexpand="false">
				                    <span>${groupItem.groupName }</span>
				                     <ul>
				                     	<c:forEach items="${groupItem.subItems }" var="workerItem">
				                        	<li><span>${workerItem.workerName }</span></li>
				                        </c:forEach>
				                     </ul>
				                 </li>
			                </c:forEach>
			            </ul>
			        </li> 
			        </c:forEach>
			    </ul>
	    	</div>
		</div>
	</div>
</body>
</html>